import 'package:cook_dinner/config/include.dart';
import 'package:flutter/material.dart';

const List<dynamic> userHomeList = [
  {
    'name': '夹心甜甜圈',
    'time': '25min',
    'num': '1956',
    'color': Color(0xff8CD614),
    'text': '简单',
  },
  {
    'name': '自制零食豆干',
    'time': '42min',
    'num': '5471',
    'color': Color(0xff48A2A9),
    'text': '一般',
  },
  {
    'name': '麻辣酱牛肉',
    'time': '56min',
    'num': '2.3万',
    'color': Color(0xffF1A90C),
    'text': '困难',
  },
  {
    'name': '清蒸大闸蟹',
    'time': '16min',
    'num': '2235',
    'color': Color(0xff8CD614),
    'text': '简单',
  },
];

class UserHomeItem extends StatelessWidget {
  const UserHomeItem(
      {Key? key,
      this.index,
      this.text,
      this.name,
      this.num,
      this.time,
      this.color})
      : super(key: key);

  final int? index;
  final String? text;
  final String? name;
  final String? num;
  final String? time;
  final Color? color;

  @override
  Widget build(BuildContext context) {
    return Container(
      width: (HYSizeFit.screenWidth - 92.rpx) / 2,
      height: 229.rpx,
      margin:
          EdgeInsets.only(bottom: 33.rpx, right: index! % 2 == 0 ? 29.rpx : 0),
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(6.rpx),
        image: DecorationImage(
          image: AssetImage('assets/images/rec0${index! + 1}.png'),
          fit: BoxFit.cover,
        ),
        boxShadow: [
          BoxShadow(
            offset: Offset(0, 2.rpx), // 垂直偏移4px，水平偏移0
            blurRadius: 4.rpx, // 模糊半径20px
            spreadRadius: 0, // 扩展半径0，保持阴影大小不变
            color: const Color(0xFF000000).withOpacity(0.1), // 颜色设置为透明度较低的黑色
          ),
        ],
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Container(
            width: 29.6.rpx,
            height: 20.3.rpx,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6.rpx),
              color: color,
            ),
            child: Text(
              text ?? '',
              style: TextStyle(color: Colors.white, fontSize: 9.rpx),
            ),
          ),
          Container(
            width: double.infinity,
            height: 65.rpx,
            padding: EdgeInsets.only(top: 6.rpx, left: 7.rpx, right: 7.rpx),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(6.rpx),
              color: Colors.white,
            ),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  crossAxisAlignment: CrossAxisAlignment.end,
                  children: [
                    SizedBox(width: 5.rpx),
                    Text(
                      name ?? '',
                      style: TextStyle(
                        fontSize: 14.rpx,
                        color: const Color(0xff333333),
                      ),
                    ),
                    SizedBox(width: 12.rpx),
                    Text(
                      time ?? '',
                      style: TextStyle(
                        fontSize: 12.rpx,
                        color: const Color(0xff999999),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 8.rpx),
                Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Image.asset(
                          'assets/images/user_avatar.png',
                          width: 25.rpx,
                        ),
                        SizedBox(width: 5.rpx),
                        Text(
                          '爱吃的小徐同学',
                          style: TextStyle(
                            fontSize: 9.rpx,
                            color: const Color(0xff999999),
                          ),
                        ),
                      ],
                    ),
                    Row(
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Image.asset(
                          'assets/images/hart.png',
                          height: 15.rpx,
                        ),
                        SizedBox(width: 5.rpx),
                        Text(
                          num ?? '',
                          style: TextStyle(
                            fontSize: 12.rpx,
                            color: const Color(0xff999999),
                          ),
                        ),
                      ],
                    ),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }
}
